home *** CD-ROM | disk | FTP | other *** search
- /* ----------------------------------------------------------------------
-
- OptionKeyDown XFCN
- version 1.0.2
-
- Written by: Paul Celestin
-
- Copyright © 1993-1995 Celestin Company, Inc.
-
- This XFCN returns true if the option key is down.
-
- No parameters required!
-
- 930927 - 1.0.0 - initial release
- 951215 - 1.0.1 - updated for CW7
- 960704 - 1.0.2 - updated for CW9
-
- ---------------------------------------------------------------------- */
-
- #include <A4Stuff.h>
- #include <HyperXCmd.h>
-
- #define PARAMETER_NUMS 0
- #define PARAMETER_TEXT "\pNo parameters required!"
-
-
- /* ----------------------------------------------------------------------
- prototypes
- ---------------------------------------------------------------------- */
- void DoIt(XCmdPtr paramPtr);
- Boolean BitTest(Ptr p, int n);
-
-
- /* ----------------------------------------------------------------------
- main
- ---------------------------------------------------------------------- */
- pascal void main(XCmdPtr paramPtr)
- {
- Str255 copyright = "\pCopyright © 1993-1996 Celestin Company, Inc.";
- long oldA4 = SetCurrentA4();
- if (paramPtr->paramCount != PARAMETER_NUMS)
- {
- paramPtr->returnValue =
- PasToZero(paramPtr,PARAMETER_TEXT);
- }
- else
- {
- DoIt( paramPtr );
- }
- SetA4(oldA4);
- }
-
- /* ----------------------------------------------------------------------
- DoIt
- ---------------------------------------------------------------------- */
- void DoIt(XCmdPtr paramPtr)
- {
- KeyMap myKeys;
-
- GetKeys(myKeys);
- if (BitTest((Ptr)myKeys, 0x3a)) /* 0x3a is the option key */
- paramPtr->returnValue = PasToZero(paramPtr,"\ptrue");
- else
- paramPtr->returnValue = PasToZero(paramPtr,"\pfalse");
-
- }
-
-
- /* ----------------------------------------------------------------------
- BitTest
- ---------------------------------------------------------------------- */
- Boolean BitTest(Ptr p, int n)
- {
- return(!!(p[n/8] & 1L<<(n%8)));
- }
-